package com.ebeijia.service.admin.impl;

import com.ebeijia.dto.ApplyWaterDto;
import com.ebeijia.mybatis.mapper.ApplyInfoMapper;
import com.ebeijia.mybatis.pojo.ApplyInfo;
import com.ebeijia.myenum.ApplyWaterSteteEnum;
import com.ebeijia.query.ApplyQuery;
import com.ebeijia.service.admin.ApplyInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by YPJ on 2016/5/16.
 */
@Service
public class ApplyInfoServiceImpl implements ApplyInfoService {
    @Resource
    private ApplyInfoMapper applyInfoMapper;
    @Override
    public List<ApplyWaterDto> queryApplyDetail(ApplyQuery applyQuery) {
        List<ApplyWaterDto> applyWaterDtos = applyInfoMapper.queryApplyDetail(applyQuery);
        for(ApplyWaterDto applyWaterDto:applyWaterDtos){

            applyWaterDto.setStatus(ApplyWaterSteteEnum.text(applyWaterDto.getStatus()));
        }
        return applyWaterDtos;
    }

    @Override
    public int queryApplyDetailCount(ApplyQuery applyQuery) {
        return applyInfoMapper.queryApplyDetailCount(applyQuery);
    }

    @Override
    public ApplyInfo selectByParimaryApplyNo(String applyNo) {
        return applyInfoMapper.selectByParimaryApplyNo(applyNo);
    }

    @Override
    public int updateStateByApplyNo(Map<String,Object> params) {
        return applyInfoMapper.updateApplyState(params);
    }

    @Override
    public List<ApplyWaterDto> selectApplyList(ApplyQuery applyQuery) {
        List<ApplyWaterDto> applyWaterDtos = applyInfoMapper.selectApplyList(applyQuery);
        for(ApplyWaterDto applyWaterDto:applyWaterDtos){

            applyWaterDto.setStatus(ApplyWaterSteteEnum.text(applyWaterDto.getStatus()));
        }
        return applyWaterDtos;
    }

    @Override
    public int selectApplyListCount(ApplyQuery applyQuery) {
        return applyInfoMapper.selectApplyListCount(applyQuery);
    }
}
